import re
from syslog2reg import *

log1 = '<318>Sep 23 11:58:25 down FILTER: SerialNum=10041-01192-2000H-J34G9-0441O GenTime="2016-09-23 11:58:25" SrcIP=172.20.21.130 DstIP=202.106.0.20 Protocol=UDP SrcPort=65332 DstPort=53 InInterface=ge0/4 OutInterface=ge0/3 FwPolicyID=1 Action=PERMIT Content="POLICY*: The packet was through because the firewall policy is permit"'
buff = 'Version={VERSION}|Mark={MARK}|DPort=$14|Proto=$8,,1|SPort=$16|DIP=$12|SIP=$13|DevID=$4|DevTime=$1|RawEventName=$4|RawID=$6|RawLevel=$10|Level=$10,,1|EventType=$19,,1|DevIP=$11|DevIPV6={DEVIP}|DevType={DEVTYPE}|Purpose=4|Count=1|Result=3|LongComment={RAW}'
buff = buff.replace('|',' ')
m_before_equal_src = re.findall('\S+(?==)',buff)

m_before_equal_dis = re.findall('\S+(?==)',log1)
matchingTable = {}
intnum = 0
for attrs in m_before_equal_src:

    print(attrs)
    for j in range(0,len(m_before_equal_dis)):
        print(str(j) + ":" + m_before_equal_dis[j])

    num = input('point its matching number!')

    if num.isdecimal():
        intnum = int(num)
        if intnum == 98:
            break
        if intnum == 99:
            continue

    else:
        matchingTable[attrs] = num
        continue
    if intnum >= 0 & intnum < len(m_before_equal_dis):
        matchingTable[attrs] = m_before_equal_dis[intnum]
        m_before_equal_dis.pop(intnum)

    print(matchingTable)

fileOb = open('MatchingTable.txt',mode='w')
fileOb.write(str(matchingTable))











